/* arch/i386/include/kernel/arch_mm.h 
 * 
 * This file is part of xnix. 
 * 
 * XNIX is free software: you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation, either version 3 of the License, or 
 * (at your option) any later version. 
 * 
 * XNIX is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with XNIX. If not, see <https://www.gnu.org/licenses/>
 */ 




#ifndef ARCH_MM_H
#define ARCH_MM_H


#ifndef __ASSEMBLER__

#include <sys/types.h>


#define KMEM_BASE 		0xc0000000lu


/* we saved it at 0x7000 (phy) at boottime, and now 
 * we'll use it to get all memory zones. 
 *
 * this structure describes a memory zone, and it was getting by 
 * bios-interrupts. 'type' field can be different numbers. 
 * */

#define E820_TYPE_RAM 	1
#define E820_TYPE_ROM 	2

/* these are not given by me, but bios. there're also other types
 * but we don't need them at this time. */


struct e820_entry {
	__uint32_t addrl;
	__uint32_t addrh;

	__uint32_t sizel;
	__uint32_t sizeh;

	__uint32_t type;
} __attribute__ ((packed));


#define E820_ADDR 	((struct e820_entry *) (KMEM_BASE + 0x7000lu))


#define PAGE_SIZE 		4096lu
#define PAGE_SHIFT 		12lu
#define PAGE_MASK 		4095lu
#define PAGE_ALIGNUP(addr) 	(((addr) + PAGE_SIZE - 1) & ~PAGE_MASK)


#endif

#endif
